package com.mcp.converter.domain.rule.manager;

import com.mcp.converter.domain.rule.compatibility.CompatibilityRule;

import java.util.List;

/**
 * 规则管理器接口
 * 负责规则的加载、查询和更新
 */
public interface RuleManager {
    
    /**
     * 规则类型枚举
     */
    enum RuleType {
        /**
         * 兼容性规则
         */
        COMPATIBILITY,
        
        /**
         * 转换规则
         */
        CONVERSION
    }
    
    /**
     * 加载规则
     * @param ruleType 规则类型
     * @return 加载结果
     */
    LoadResult loadRules(RuleType ruleType);
    
    /**
     * 查询规则
     * @param <T> 规则类型
     * @param ruleType 规则类型
     * @param condition 查询条件
     * @return 规则列表
     */
    <T> List<T> queryRules(RuleType ruleType, RuleQueryCondition condition);
    
    /**
     * 更新规则
     * @param rule 规则
     * @return 更新结果
     */
    UpdateResult updateRule(CompatibilityRule rule);
    
    /**
     * 获取所有不兼容函数
     * @return 所有函数规则中定义的不兼容函数集合
     */
    java.util.Set<String> getAllIncompatibleFunctions();
    
    /**
     * 规则加载结果类
     */
    class LoadResult {
        private boolean success;
        private String message;
        private int loadedCount;
        
        public LoadResult(boolean success, String message, int loadedCount) {
            this.success = success;
            this.message = message;
            this.loadedCount = loadedCount;
        }
        
        public boolean isSuccess() {
            return success;
        }
        
        public String getMessage() {
            return message;
        }
        
        public int getLoadedCount() {
            return loadedCount;
        }
    }
    
    /**
     * 规则更新结果类
     */
    class UpdateResult {
        private boolean success;
        private String message;
        
        public UpdateResult(boolean success, String message) {
            this.success = success;
            this.message = message;
        }
        
        public boolean isSuccess() {
            return success;
        }
        
        public String getMessage() {
            return message;
        }
    }
    
    /**
     * 规则查询条件类
     */
    class RuleQueryCondition {
        private String id;
        private String name;
        private String type;
        
        public String getId() {
            return id;
        }
        
        public void setId(String id) {
            this.id = id;
        }
        
        public String getName() {
            return name;
        }
        
        public void setName(String name) {
            this.name = name;
        }
        
        public String getType() {
            return type;
        }
        
        public void setType(String type) {
            this.type = type;
        }
    }
}
